package com.pangu.export.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pangu.export.entity.TableColumn;
import com.pangu.export.mapper.TableColumnMapper;
import com.pangu.export.service.TableColumnService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * Created by etfox on 2019/10/24 17:39
 */
@Service
public class TableColumnServiceImpl extends ServiceImpl<TableColumnMapper, TableColumn> implements TableColumnService {

    /**
     * 查询数据库所有表的表结构/查询指定的数据库表的表结构
     */
    @Override
    public List<TableColumn> getAllTableColumn(String dataSourceName, String tableName) {
        if (StringUtils.isEmpty(dataSourceName)) {
            throw new RuntimeException("请输入数据库名");
        }
        // TODO 查询数据库和表是否存在
        return baseMapper.getAllTableColumn(dataSourceName, tableName);
    }

}
